﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Home_ad_ad_sp_daugia : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Add_Click(object sender, EventArgs e)
    {
        string[] tokens = FileUpload_upload.FileName.Split('.');
        string extension = tokens[tokens.Length - 1].ToLower();
        double size = (double)FileUpload_upload.FileBytes.Length / (1024 * 1024);
        // check whether the uploaded file is an image and file size less than 1MB
        if (size > 1)
            Lbmasse.Text = "MAXIMUN 1MB";
        else if (extension == "jpg" || extension == "gif" || extension == "jpeg")
        {
            // generate relative & absolute path to save the uploaded file
            string strRelativePath = "../images/sanpham/dienthoai/deban/" + FileUpload_upload.FileName;
            string strAbsolutePath = Server.MapPath(strRelativePath);
            // save uploaded file
            FileUpload_upload.SaveAs(strAbsolutePath);
           // Lbmasse.Text = strAbsolutePath + " Upload thành công.";
            Lbmasse.Text = " File được tải lên thành công thành công.";
        }
        else
           // lblMessage.Text = 
            Lbmasse.Text="File upload phải là jpg hoặc gif.";
    }
}
